Skip to content

Conversation

@serhiy-katsyuba-intel
Copy link
Contributor

fast_get() for the same data can be called by multiple clients from the same or other cores. Since sram_ptr points to cached memory, writeback is needed after memcpy() to also copy data to uncached memory. When fast_get() is called a second time for the same data, invalidate() is used to bring shared data into another core's cache.

This fixes tests which use two SRC modules.

fast_get() for the same data can be called by multiple clients from
the same or other cores. Since sram_ptr points to cached memory, writeback
is needed after memcpy() to also copy data to uncached memory. When
fast_get() is called a second time for the same data, invalidate() is used
to bring shared data into another core's cache.

This fixes tests which use two SRC modules.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
@serhiy-katsyuba-intel
Copy link
Contributor Author

@lgirdwood, Zephyr / build-linux (zmain, imx8 imx8x imx8m imx8ulp) CI failes with final link failed: No space left on device.

@kv2019i kv2019i requested review from Copilot and jsarha January 15, 2026 16:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a cache coherency issue in the fast_get() function when the same data is accessed by multiple callers across different cores. The changes ensure proper cache alignment and synchronization for shared memory access.

Changes:

  • Modified memory allocation to use cache-line alignment instead of no alignment
  • Added cache writeback operation after copying data to ensure visibility across cores

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments inline but looking at the modified code alone, seems good.

entry->size = size;
entry->sram_ptr = ret;
memcpy_s(entry->sram_ptr, entry->size, dram_ptr, size);
dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you @jsarha and @lyakh comment on the semantics? This seems correct in the sense to ensure the memcpy actually reaches sram, but I'm not sure of the fast_get API semantics whether this is correct usage (iow are there other places that would need modifications if used by multiple cores).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes, this looks correct and an oversight in the original implementation - thanks @serhiy-katsyuba-intel ! This should cover cases like multiple SRC instances on different cores using the same configuration, so they'll re-use the SRAM copy of the parameters (@singalsu will correct me if I'm mixing things up). So, @kv2019i, yes, this looks correct, and no, I don't think it's a part of a systemic oversight - this is a very specific fast-get aspect - sharing copies of data between instances. And fast-get context (struct sof_fast_get_entry instances) should be kept synchronised between cores too, but those are already allocated as uncached.

@kv2019i
Copy link
Collaborator

kv2019i commented Jan 16, 2026

https://sof-ci.01.org/sofpr/PR10484/build18525/build/index.html should be harmless, but as it blocks Linux test execution, let me try to rekick CI once more.

@kv2019i
Copy link
Collaborator

kv2019i commented Jan 16, 2026

SOFCI TEST

@kv2019i
Copy link
Collaborator

kv2019i commented Jan 16, 2026

Looks good now, proceeding with merge.

@kv2019i kv2019i merged commit 259402e into thesofproject:main Jan 16, 2026
36 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants